Merged
Conversation
Open
yegct
commented
Apr 13, 2022
| @@ -1,59 +1 @@ | |||
| class BitArray | |||
Contributor
Author
There was a problem hiding this comment.
Moved to lib/bitarray/bit_array.rb.
yegct
commented
Apr 13, 2022
| @@ -0,0 +1,58 @@ | |||
| class BitArray | |||
| attr_reader :field, :reverse_byte, :size | |||
Contributor
Author
There was a problem hiding this comment.
Added reverse_byte to the publicly accessible attributes.
yegct
commented
Apr 13, 2022
| @field.each_byte.inject(0) { |a, byte| (a += 1; byte &= byte - 1) while byte > 0 ; a } | ||
| end | ||
|
|
||
| private def byte_position(position) |
Contributor
Author
There was a problem hiding this comment.
Marked this method private.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Minor cleanups. This PR clears the way for this future PR allowing dumping and loading contents to disk.
Specifically:
lib/bitarray-array.rbfilelib/bitarray.rbtolib/bitarray/bit_array.rb, addlib/bitarray.rbthat just requires the file from the subdirectory. This makes it easy to add additional classes, later.reverse_byteaccessorbyte_positionprivatetest/test_bitarray.rbtotest/test_bit_array.rbTests
Additionally, note there are almost no code changes here. Nevertheless, I tested it with my bitarray consisting of a little over 2 billion bits and the code worked identically to that in
master.